﻿//
// Copyright (c) 2024 BPer
//
#ifndef BPERCAPTURE_WIN_API_BPERWINAUDIOAPIAEC_H_
#define BPERCAPTURE_WIN_API_BPERWINAUDIOAPIAEC_H_
#include <bperaudiodev/win/BPerAudioApiCapture.h>
#include <bperaudiodev/win/BPerWinAudioApi.h>
#include <bperaudiodev/BPerAudioCaptureData.h>
#include <bperutil/sys/BPerLoadLib.h>
#include <bperutil/BPerAvInfoType.h>
#ifdef _MSC_VER
#include <mmdeviceapi.h>
#include <dmo.h>

class BPerWinAudioApiAec:public BPerAudioApiCapture,public BPerWinAudioApi {
public:
    BPerWinAudioApiAec();
	virtual ~BPerWinAudioApiAec();
	void setCaptureCallback(BPerCaptureCallback* cb);
    int initCapture();
    int startCpature();
    int stopCapture();
    void captureThread();
    int getAudioOutLength(){return 640;}


     int initRecordingDMO();
     int setDMOProperties();
     int getRenderIndex();
     BPerAudioCaptureData m_audioData;
     HANDLE m_shutdownEvent;

	void stop();
protected:
	void run();
	void startLoop();
	void stopLoop();
	 int setBoolProperty(IPropertyStore* ptrPS, REFPROPERTYKEY key,VARIANT_BOOL value);
	 int setVtI4Property(IPropertyStore* ptrPS,REFPROPERTYKEY key,LONG value);
	int m_loops;

private:
	   IMediaObject* m_dmo;


	    DWORD m_dwStatus;

	    int m_micIndex;
	    BYTE* m_dataBuf;
	   IPropertyStore* m_ps;

	   BPerFrame m_audioFrame;
};
#endif
#endif /* BPERCAPTURE_WIN_API_BPERWINAUDIOAPIAEC_H_ */
